package hu.myai.calculators;

import hu.myai.model.db.AxHistory;
import hu.myai.model.misc.KeyValue;
import hu.myai.model.sp.StockPivot;

import java.util.ArrayList;
import java.util.List;

public class RateOfChange extends AbstractCalculator {

	private List<Double> rocList = new ArrayList<Double>();

	public RateOfChange(String symbol, StockPivot maxStock, StockPivot minStock, List<AxHistory> stockList,
			List<StockPivot> stockPivotList) {
		super(symbol, maxStock, minStock, stockList, stockPivotList);
		// TODO Auto-generated constructor stub
	}

	@Override
	public KeyValue[] getNexts() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int calculator(int mode) {

		int stockListSize = stockList.size();
		if (stockListSize > mode) {
			for (int i = 0; i < mode; i++) {
				rocList.add(i, null);
			}

			for (int i = mode; i < stockListSize; i++) {
				rocList.add(i, (stockList.get(i).getClose() - stockList.get(i - mode).getClose())
						/ stockList.get(i - mode).getClose() * 100);
			}
		} else
			return -1;

		return 0;
	}

	public List<Double> getRocList() {
		return rocList;
	}
}
